
var LightenDarkenColor = require('../@Vast-Package/utils/LightenDarkenColor');



Component({

	externalClasses:['custom-style'],
	/**
	 * 组件的属性列表
	 */
	properties: {

    modMargin:{                 // 组件外边距
      type: String,
      value: "0"
    },
    width: {                    // 按钮宽度
      type: String,
      value: "680rpx"
    },								
		height: {								    // 按钮高度
      type: String,
      value: "85rpx"
    },		
    fontSize:{                    // 字体大小
      type: String,
			value: "32rpx"
    },							
    iconSize:{										// 按钮图标的大小
			type: String,
			value: "42rpx"
    },
    bt_radius: {						      // 按钮圆角大小
      type: String,
			value: "15rpx"
    },
    color: {      								// 按钮与图标的 颜色
      type: String,
			value: "white"
    },

		btType:{									    // 按钮类型：button（button组件的按钮）、view（view组件做的按钮）
			type: String,
			value: "button"
		},

		iconfamily:{							// 图标族 =>  组件内置图标：vast-iconfont  自定义图标，如：iconfont
			type: String,
			value: "vast-iconfont"
		},
		isCustomStyle: {
			type: Boolean,
			value: false
    },
    

		hover_stop_propagation: Boolean,
		hover_start_time: Number,
		hover_stay_time: Number,
		session_from: String,
		send_message_title: String,
		send_message_path: String,
		send_message_img: String,
		app_parameter: String,
		show_message_card: String,
		open_type: String,						// 微信开放能力（请参阅微信开放文档的open-type说明）
		isGradualCol: Boolean,				// 是否启用渐变背景色
    isDisabled: Boolean,					// 是否禁用按钮
    

		


		bckCol:{ 											// 按钮背景色设置（由于bckCol有可能在父组件页面需要用其他“方法”获取，从而导致迟滞传入子组件，所以需要用observer进行监听）
      type: String,
      observer: function(newVal, oldVal) { 
				// console.log('properties-bckCol', newVal)
				if(newVal){
					var lightCol = this.data.isGradualCol ? LightenDarkenColor.LightenDarkenColor(newVal,85) : newVal		// col为hex颜色值，正数-变浅；负数-变深
					this.setData({
						lightCol,
						bckCol_obs: newVal
					})
				}
      }
    },

		// bckCol: String,						// 按钮背景色
		
		
		lineHeight: String,						// 按钮文字行高
		
		isFontweight: Boolean,				// 按钮文字加粗
		
		iconName: String,							// 按钮图标的classname
		bt_text: String,							// 按钮文字
		bt_text_lineHieght: String,   // 按钮文字的行高

	},



	/**
	 * 组件的初始数据
	 */
	data: {





	},

	lifetimes: {
	
		attached() {
			// console.log(this.data.isCustomStyle)
		}
	},

	/**
	 * 组件的方法列表
	 */
	methods: {


		onClick(event){
			var Click = event.detail
			this.triggerEvent("onClick",Click) 
		},

		
		// 用户点击该按钮时，会返回获取到的用户信息，回调的detail数据与wx.getUserInfo返回的一致，open-type="getUserInfo"时有效
		GetUserInfo(event){
			// console.log(event)
			var GetUserInfo = event.detail
			this.triggerEvent("GetUserInfo",GetUserInfo)  
		},

		// 获取用户手机号回调，open-type=getPhoneNumber时有效
		GetPhoneNumber(event){
			// console.log(event)
			var GetPhoneNumber = event.detail
			this.triggerEvent("GetPhoneNumber",GetPhoneNumber)  
		},

		// 客服消息回调，open-type="contact"时有效
		Contact(event){
			// console.log(event)
			var Contact = event.detail
			this.triggerEvent("Contact",Contact)  
		},

		// 打开 APP 成功的回调
		LaunchApp(event){
			// console.log(event)
			var LaunchApp = event.detail
			this.triggerEvent("LaunchApp",LaunchApp)  
		},

		// 在打开授权设置页后回调，open-type=openSetting时有效
		OpenSetting(event){
			// console.log(event)
			var OpenSetting = event.detail
			this.triggerEvent("OpenSetting",OpenSetting)  
		},

		// 当使用开放能力时，发生错误的回调，open-type=launchApp时有效
		Error(event){
			// console.log(event)
			var Error = event.detail
			this.triggerEvent("Error",Error)  
		},

		// 获取用户头像回调
		Chooseavatar(event){
			// console.log(event)
			var Chooseavatar = event.detail
			this.triggerEvent("Chooseavatar",Chooseavatar)  
		},

			
	}


		/** BUTTON: eventhandle */
		
		// bindcontact
		// bindgetphonenumber
		// binderror
		// bindopensetting
		// bindlaunchapp
		// bindchooseavatar

	
})
